﻿using System;
using EPiServer.Core;
using TemplateFoundation.PageTypeIcons.IconHandlers;

namespace  TemplateFoundation.PageTypeIcons {

    /// <summary>
    /// <para>Attribute used to show an icon when a property is empty.</para>
    /// </summary>
    public class PropertyEmptyIconAttribute : StatusIconAttribute {

        /// <summary>
        /// <para>Initializes a new PropertyEmptyIconAttribute.</para>
        /// </summary>
        /// <param name="imageUrl">The virtual path to the icon to use.</param>
        /// <param name="toolTip"><para>The tool tip to show on mouseover.</para><para>If the value isn't found in the language file, it's considered to be a string constant tool tip.</para></param>
        /// <param name="propertyName">The name of the property to check.</param>
        /// <param name="excludedPageTypes">The excluded types of pages.</param>
        /// <param name="hideIfShortcut">A value indicating if the icon should be omitted of the LinkType of the page is set to point somewhere else.</param>
        public PropertyEmptyIconAttribute(string imageUrl, string toolTip, string propertyName, Type[] excludedPageTypes, bool hideIfShortcut)
            : base(imageUrl, toolTip) {
            this.ExcludedPageTypes = excludedPageTypes;
            this.Handler = new PropertyHandler(propertyName, String.Empty, true, this.ImageUrl, LanguageManager.Instance.TranslateFallback(this.ToolTip, this.ToolTip), excludedPageTypes, hideIfShortcut);
        }

        /// <summary>
        /// <para>The excluded types of pages.</para>
        /// <para>Matches are only made on pages that aren't in the list of exluded page types.</para>
        /// </summary>
        public Type[] ExcludedPageTypes {
            get;
            private set;
        }
    }
}